import requests
from requests.exceptions import ConnectionError

# 请求头信息
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
    'Accept-Encoding': 'gzip, deflate, sdch'
}


def get_page(url, options={}):
    """
    抓取代理网页数据
    :param url: 代理网页地址
    :param options: 参数
    :return:
    """
    req_headers = dict(headers, **options)
    try:
        response = requests.get(url, headers=req_headers)
        print('所取代理网页成功', url, response.status_code)
        if response.status_code == 200:
            return response.text
    except ConnectionError:
        print('抓取代理网页失败', url)
        return None
